package com.imut.hcdp.service.impl;

import java.util.List;

import com.imut.hcdp.domain.HcdpOrder;
import com.imut.hcdp.domain.HcdpTrainRoute;
import com.imut.hcdp.domain.HcdpTrainSeat;
import com.imut.hcdp.mapper.HcdpOrderMapper;
import com.imut.hcdp.mapper.HcdpTrainRouteMapper;
import com.imut.hcdp.mapper.HcdpTrainSeatMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.imut.hcdp.mapper.HcdpPassengerMapper;
import com.imut.hcdp.domain.HcdpPassenger;
import com.imut.hcdp.service.IHcdpPassengerService;


@Service
public class HcdpPassengerServiceImpl implements IHcdpPassengerService
{
    @Autowired
    private HcdpPassengerMapper hcdpPassengerMapper;

    @Autowired
    private HcdpOrderMapper hcdpOrderMapper;

    @Autowired
    private HcdpTrainRouteMapper hcdpTrainRouteMapper;

    @Autowired
    private HcdpTrainSeatMapper hcdpTrainSeatMapper;


    @Override
    public HcdpPassenger selectHcdpPassengerById(Long id)
    {
        return hcdpPassengerMapper.selectHcdpPassengerById(id);
    }


    @Override
    public List<HcdpPassenger> selectHcdpPassengerList(HcdpPassenger hcdpPassenger)
    {
        List<HcdpPassenger> hcdpPassengers = hcdpPassengerMapper.selectHcdpPassengerList(hcdpPassenger);
        for (int i = 0; i < hcdpPassengers.size(); i++) {
            HcdpPassenger hcdpPassenger1 = hcdpPassengers.get(i);
            HcdpOrder hcdpOrder = hcdpOrderMapper.selectHcdpOrderById(hcdpPassenger1.getOrderId());
            hcdpPassenger1.setHcdpOrder(hcdpOrder);
            HcdpTrainRoute hcdpTrainRoute = hcdpTrainRouteMapper.selectHcdpTrainRouteById(hcdpPassenger1.getRouteId());
            hcdpPassenger1.setHcdpTrainRoute(hcdpTrainRoute);
            //座位
            Long seattype = hcdpPassenger1.getSeattype();
            HcdpTrainSeat hcdpTrainSeat = hcdpTrainSeatMapper.selectHcdpTrainSeatById(seattype);
            hcdpPassenger1.setHcdpTrainSeat(hcdpTrainSeat);

        }
        return hcdpPassengers;
    }


    @Override
    public int insertHcdpPassenger(HcdpPassenger hcdpPassenger)
    {
        return hcdpPassengerMapper.insertHcdpPassenger(hcdpPassenger);
    }


    @Override
    public int updateHcdpPassenger(HcdpPassenger hcdpPassenger)
    {
        return hcdpPassengerMapper.updateHcdpPassenger(hcdpPassenger);
    }


    @Override
    public int deleteHcdpPassengerByIds(Long[] ids)
    {
        return hcdpPassengerMapper.deleteHcdpPassengerByIds(ids);
    }


    @Override
    public int deleteHcdpPassengerById(Long id)
    {
        return hcdpPassengerMapper.deleteHcdpPassengerById(id);
    }

    @Override
    public void deleteHcdpPassengerByOrderId(Long id) {
        hcdpPassengerMapper.deleteHcdpPassengerByOrderId(id);

    }
}
